package com.cyy.demo.common;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class ConsumerTest {

    //接收字符串
    @KafkaListener(topics = {"test"})
    public void getMessage(ConsumerRecord<String,String> record){
        System.out.println("消费信息"+record.value());
    }

    //接收byte数组
//    @KafkaListener(topics = {"test_byte"})
    public void getMessageByte1(ConsumerRecord<String, byte[]> record){
        System.out.println("消费信息"+new String(record.value()));

    }

        @KafkaListener(topics = {"test"})
    public void getMessageByte2(ConsumerRecord<byte[], byte[]> record){
        System.out.println("消费信息"+new String(record.value()));

    }
}
